package Homework.Date7_06;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import Homework.Date7_06.Subject;

public class Subject_CRUD {
	public static void main(String[] args) {
		// 修改
//		SqlSession session = MyBatisUtil.link();
//		SubjectDao subjectDao = session.getMapper(SubjectDao.class);
//		Subject s = new Subject(58, "shuqi", 180, 12);
//		int a = subjectDao.update(s);
//		System.out.println(a);
//		MyBatisUtil.close(session);
		// 删除
//		SqlSession session = MyBatisUtil.link();
//		SubjectDao subjectDao = session.getMapper(SubjectDao.class);
//		int b = subjectDao.del(58);
//		System.out.println(b);
//		MyBatisUtil.close(session);
		// 增加
//		SqlSession session = MyBatisUtil.link();
//		SubjectDao subjectDao = session.getMapper(SubjectDao.class);
//		Subject s1 = new Subject("八神烤死", 180, 13);
//		int c = subjectDao.add(s1);
//		System.out.println(c);
//		MyBatisUtil.close(session);
		// 查看
//		SqlSession session = MyBatisUtil.link();
//		SubjectDao subjectDao = session.getMapper(SubjectDao.class);
//		Subject d = subjectDao.get(1);
//		System.out.println(d.toString());
//		MyBatisUtil.close(session);
		// 分页
		SqlSession session = MyBatisUtil.link();
		SubjectDao subjectDao = session.getMapper(SubjectDao.class);
		List<Subject> list = subjectDao.paging(5, 15);
		for (Subject a : list) {
			System.out.println(a.toString());
		}
		MyBatisUtil.close(session);
	}
}
